// product controller
const { code } = require('../utils/stateModel')
const Product = require('../db/models/productSchema')
const ProductID = require('../db/models/productID')
const productIntroduct = require("../db/models/productIntroductionSchema")
const pagerFun = require('../utils/pager')
const { successModel, errorModel } = require("../utils/stateModel")

// 获取产品信息
const getProductList = async (ctx, { pageNum, pageSize, ...params }) => {
  try {
    const proList = Product.find(params, 'productName productIntroduction productType productImg productCreatTime productEndTime productamount');
    const list = await proList.skip(pagerFun(pageNum, pageSize).skipIndex).limit(pagerFun(pageNum, pageSize).pager.pageSize);

  } catch (error) {
    return ctx.body = new errorModel({
      productList: [],
      errorMessage: "查询产品列表失败"
    })
  }
}

module.exports = {
  getProductList
}